package com.xgg.taiwuinfo.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import com.xgg.taiwuinfo.R;

import java.util.List;
import java.util.Map;

public class FilterAdapter extends SimpleAdapter {
    private LayoutInflater layoutInflater;
    private List<Map<String, String>> m_list;

    public FilterAdapter(Context context, List<Map<String, String>> data, int resource, String[] from, int[] to)
    {
        super(context, data, resource, from, to);
        //m_ctx = context;
        layoutInflater = LayoutInflater.from(context);
        this.m_list = data;
    }

    @Override
    public int getCount() {
        return m_list.size();
    }

    @Override
    public Object getItem(int arg0) {
        return m_list.get(arg0);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup arg2)
    {
        if(convertView == null)
        {
            convertView = layoutInflater.inflate(R.layout.item_filter, null);
        }
        Map<String,String> obj = m_list.get(position);

        TextView txt_name = convertView.findViewById(R.id.txt_name);
        txt_name.setText(obj.get("name"));
        txt_name.setTextColor(Color.WHITE);
        return convertView;
    }
}
